﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Coco.Enums;

namespace Coco.Library.Helpers
{
    public class DateHelper
    {
        public double GetTimeSpan(DateTime dateStart, DateTime dateEnd, DisplayKindValue type)
        {
            try
            {
                TimeSpan tsStart = TimeSpan.FromTicks(dateStart.Ticks);
                TimeSpan tsEnd = TimeSpan.FromTicks(dateEnd.Ticks);

                TimeSpan ts = tsStart.Subtract(tsEnd).Duration();

                switch (type)
                {
                    case DisplayKindValue.Day:
                        return ts.TotalDays;// > 1 ? ts.TotalDays : 0;
                    case DisplayKindValue.Hour:
                        return ts.TotalHours;// > 1 ? ts.TotalHours : 0;
                    case DisplayKindValue.Second:
                        return ts.TotalSeconds;// > 1 ? ts.TotalSeconds : 0;
                    case DisplayKindValue.Minute:
                        return ts.TotalMinutes;// > 1 ? ts.TotalMinutes : 0;
                    default:
                        return ts.TotalDays;// > 1 ? ts.TotalDays : 0;
                }
            }
            catch
            {
                return 0;
            }
        }

        public int CompareDate(DateTime dateStart, DateTime dateEnd)
        {
            TimeSpan tsStart = TimeSpan.FromTicks(dateStart.Ticks);
            TimeSpan tsEnd = TimeSpan.FromTicks(dateEnd.Ticks);

            return tsStart.CompareTo(tsEnd);
        }
    }
}
